package archer.back.models

import io.circe.{ Decoder, Encoder }
import io.circe.generic.auto._
import utils.CirceUtils

case class CrawlActionWrap(
  id: Int,
  isFinish: Boolean,
  isRunning: Boolean,
  planId: Int,
  urlsLeft: Int,
  finishedTime: Option[java.sql.Timestamp],
  lastestRunTime: java.sql.Timestamp)

object CrawlActionWrap extends CirceUtils {

  implicit val dateEncoder: Encoder[java.sql.Timestamp] =
    timestampEncoderFromPattern("yyyy-MM-dd HH:mm:ss.SSS")
  implicit val dateDecoder: Decoder[java.sql.Timestamp] =
    timestampDeocderFromPattern("yyyy-MM-dd HH:mm:ss.SSS")

  implicit val encoder = implicitly[Encoder[CrawlActionWrap]]
  implicit val decoder = implicitly[Decoder[CrawlActionWrap]]

}
